import Dialog from '../../miniprogram_npm/@vant/weapp/dialog/dialog';

Component({
    options: {
        multipleSlots: true,
        addGlobalClass: true
    },

    properties: {
        // 是否跳转
        isLink: {
            type: Boolean,
            value: false
        },
        // 是否主页跳转
        isTab: {
            type: Boolean,
            value: false
        },
        // 跳转链接
        url: {
            type: String,
            value: ''
        },
        // 是否圆角
        round: {
            type: Boolean,
            value: true
        },
        opentype:{
            type: Number,
            value: 0
        },
        // 箭头方向
        positon: {
            type: String,
            value: 'right',
        },
        // y轴翻转
        rotate: {
            type: Boolean,
            value: false
        },
        // 是否显示左边图标
        showPre: {
            type: Boolean,
            value: false
        },
        pre: {
            type: String,
            value: '/image/icon/arrow.png'
        },
        // 是否显示右边图标
        showSuffix: {
            type: Boolean,
            value: true
        },
        suffix: {
            type: String,
            value: '/image/icon/arrow.png'
        },
        suffixWrite: {
            type: String,
            value: '/image/icon/arrowWrite.png'
        },
        position: {
            type: String,
            value: 'top'
        },
        white: {
            type: Boolean,
            value: false
        },
        customClass: {
            type: String,
            value: 'size'
        },
        size:{
            type: String,
            value: 'normal'
        },
        color:{
            type: String,
            value: '#000'
        },
        btnsize:{
            type: String,
            value: ''
        },
    },

    methods: {
        onClick () {
            const { isLink, url, isTab } = this.data
            
            if (!isLink) return

            if (url === '')  {
                Dialog.alert({
                    title: '提示',
                    message: '敬请期待',
                }).then(() => {});
            }
            
            if (isTab) {
                wx.switchTab({ url })
            } else {
                wx.navigateTo({ url })
            }
        }
    }
})
